# 1 "grldrstart.S"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "grldrstart.S"
# 41 "grldrstart.S"
 .file "mbrstart.S"
# 51 "grldrstart.S"
 .text
 .globl start, _start
start:
_start:
_start1:
 .code16
 . = _start1 + 0x00
# 79 "grldrstart.S"
 jmp 1f
 . = _start1 + 0x02
 .byte 0x80
# 97 "grldrstart.S"
 . = _start1 + 0x03
 .byte 0
# 110 "grldrstart.S"
 . = _start1 + 0x04
 .word 0x3920
 . = _start1 + 0x06
 .byte 0xff
 .byte 0xff
 . = _start1 + 8
# 147 "grldrstart.S"
 . = _start1 + 0x60
1:
 cli
 xorw %bx, %bx
 movw %bx, %ss
 movw $0x580, %sp
 call 1f
1:
 popw %bx                       #get offset of 1b
 subw $(1b - _start1), %bx      #get offset of _start
 shrw $4, %bx
 movw %cs, %ax
 addw %ax, %bx                  #get Segment of _start
# 209 "grldrstart.S"
 movw %bx, %ds
 pushw %bx
 .byte 0x6A, (1f - _start1)     #pushw $(1f - _start1)
 lret                           #goto to 1f
 . = . - (. - _start1) / 0x80
1:                              #now offset of _start1 is 0
# 229 "grldrstart.S"
 pushw $0x2000
 popw %ss
 movw $0x9000, %sp              #ss:sp = 0x29000
 sti
# 246 "grldrstart.S"
 pushw %ss
 popw %es
 movw $((pre_stage2_start - _start1) >> 9), %cx #cylinder number (ch)  sector number (cl)
1:#read mbr to 0x2000:0x0000
 movw $0x0201, %ax              #int 13H /ah=2 al=1
 movw %cx, %bx
 decw %bx
 shlw $9, %bx
 movw $0x0080, %dx              #dl=0x80
 pushw %cx
 pushw %bx
 call int13
 popw %bx
 popw %cx
 jc 1f                          #on error goto 1f
 loop 1b
 negb %ah                       #set CF=1 if ah non-zero ;subb $0, &ah 
1:
 pushw %cs
 popw %ds
 pushfw
 xorw %si, %si
 xorw %di, %di
 movw $223, %cx
 cld
 repz movsw                     #move 446 btyes of mbr to 0x2000:0000
disk_serial_number_structure:
# 296 "grldrstart.S"
 movw $0x1FFC, %bx              #offset of Boot Signature
 movl $0x93cb4d05, %eax
# 309 "grldrstart.S"
disk_serial_number_structure_end:
 cmpl %eax, (%bx)               #ds=cs=_start
 jne 1f                         #no Boot Signature goto 1f
 call move_helper
1:
 ljmp $0x2000, $(1f - _start1)
# 333 "grldrstart.S"
1:
 pushw %ss
 popw %ds
 cmpl %eax, (%bx)               #ss=ds=es=0x2000
 je 1f
 pushal
# 372 "grldrstart.S"
 movw $3, %di
2:
 movw $((((pre_stage2_start - _start1) >> 9) - 1) + 0x200), %ax
 cwd
 movw $0x200, %bx
 movw $2, %cx
 call read_disk_with_reset_and_dec_di
 jnc 3f
 jnz 2b
3:
 popal
 cmpl %eax, (%bx)
 jne Error_or_prev_MBR          #no Boot Signature goto Error_or_prev_MBR ;shutdown
 movw $0xff00, 0x06
 andb $0xFE, 0x02
1:
 popfw
 jc try_floppy                  #hdd read error
1:                              #find grldr
 pushw %cs
 popw %ds
 lodsw
 movb %ah, %dh
 lodsw
 movw %ax, %cx
 andb $63, %al
 jz helper_call_c
 movb $0x01, %al
7:
 movw $3, %di
2:
 movb $0x02, %ah
 pushw $0xd00
 popw %es
 xorw %bx, %bx
# 447 "grldrstart.S"
 call read_disk_with_reset_and_dec_di
 jnc helper_call
 jnz 2b
helper_call_c:
 stc
helper_call:
# 469 "grldrstart.S"
 call helper_start
 ja filesystem_boot
6:
add_sub_si:
# 485 "grldrstart.S"
 addw $12, %si
 . = add_sub_si + 3
 cmpw $0x01fe, %si
 jb 1b
 ja 5f
try_floppy:
 movw $0x31b2, %si
# 513 "grldrstart.S"
 movb $4, %al
 movw $1, %cx
 xorw %dx, %dx
 jmp 7b
5:
Error_or_prev_MBR:
 movw $(message_string - _start1), %si
 call print_message
3: jmp 3b
int13:
 pushw %ds
 pushw %es
 pushw %dx
 pushw %si
 pushw %di
 pushw %bp
 stc
 int $0x13
 popw %bp
 popw %di
 popw %si
 popw %dx
 popw %es
 popw %ds
 ret
# 619 "grldrstart.S"
try_next_partition:
 cli
 movw $0x2000, %ax
 movw %ax, %ss
 movw $(0x9000-36), %sp
 sti
 popal
 popw %es
 popw %ds
 jmp add_sub_si
read_disk_with_reset_and_dec_di:
 pushaw
3:
 pushw %ax
 pushw %bx
 pushw %cx
 decb %al
 addb %al, %cl
 shlb $1, %al
 addb %al, %bh
 movb $0x01, %al
 call int13
 popw %cx
 popw %bx
 popw %ax
 jc 3f
 decb %al
 jnz 3b
3:
 popaw
 jnc 3f
 pushaw
 xorw %ax, %ax
 call int13
 popaw
 decw %di
 stc
3:
 ret
3:
 movb $0x0e, %ah
 int $0x10
print_message:
 lodsb %cs:(%si), %al
 cmpb $0, %al
 jne 3b
 ret
message_string:
 .ascii "\r\nMissing MBR-helper.\0"
#;buggy_bios_string:
#;
#; .ascii "\r\nBuggy BIOS!\0"
# 705 "grldrstart.S"
 . = . - ((. - _start1) / 0x1b9)
# 778 "grldrstart.S"
 . = _start1 + 0x1fe
# 789 "grldrstart.S"
 .word 0xaa55
 . = _start1 + 0x200
# 841 "grldrstart.S"
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 . = _start1 + 0x256
 .byte 0x90, 0x90
 . = _start1 + 0x258
 .byte 0x90, 0x90
 . = _start1 + 0x25a
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 .byte 0x90, 0x90
 . = _start1 + 0x26a
1:
 movb $0x7F, %dl
 jmp _start1
# 1267 "grldrstart.S"
 . = _start1 + 0x400
# 1366 "grldrstart.S"
Entry_32:
 jmp 1f
 . = Entry_32 + 0x02
# 1390 "grldrstart.S"
 .byte 0x90
 . = Entry_32 + 0x03
 .ascii "GRLDR   "
 . = Entry_32 + 0x0b
 .word 0x200
 . = Entry_32 + 0x0d
 .byte 1
 . = Entry_32 + 0x0e
 .word 1
 . = Entry_32 + 0x10
 .byte 2
 . = Entry_32 + 0x11
 .word 0
 . = Entry_32 + 0x13
 .word 0
 . = Entry_32 + 0x15
 .byte 0xf8
 . = Entry_32 + 0x16
 .word 0
 . = Entry_32 + 0x18
 .word 18
 . = Entry_32 + 0x1a
 .word 2
 . = Entry_32 + 0x1c
 .long 0
 . = Entry_32 + 0x20
 .long 0
 . = Entry_32 + 0x24
 .long 0
 . = Entry_32 + 0x28
 .word 0
 . = Entry_32 + 0x2a
 .word 0
 . = Entry_32 + 0x2c
 .long 0
 . = Entry_32 + 0x30
 .word 0
 . = Entry_32 + 0x32
 .word 6
 . = Entry_32 + 0x34
 .long 0
 .long 0
 .long 0
 . = Entry_32 + 0x40
# 1536 "grldrstart.S"
 .byte 0
 . = Entry_32 + 0x41
 .byte 0
 . = Entry_32 + 0x42
 .byte 0x29
 . = Entry_32 + 0x43
 .long 0x0AC4AF63
 . = Entry_32 + 0x47
 .ascii "NO NAME    "
 . = Entry_32 + 0x52
 .ascii "FAT32   "
# 1608 "grldrstart.S"
 . = Entry_32 + 0x5a
1:
 cli
 cld
 . = Entry_32 + 0x5c
 movb $0xff, %dh
 cmpb $0xff, %dh
 jne 1f
 movb $0, %dl
1:
 xorw %ax, %ax
 movw $0x7c00, %bp
# 1644 "grldrstart.S"
 movw %ax, %ss
 leaw -0x20(%bp), %sp
 sti
 movw %dx, 0x40(%bp)
 pushw %ss
 movb $0x41, %ah
 movw $0x55AA, %bx
 int $0x13
 popw %ds
 jc 1f
 cmpw $0xAA55, %bx
 jne 1f
 testb $1, %cl
 jz 1f
 movb $0x42, (ebios_32 - 1 - Entry_32 + 0x7c00)
1:
 pushw %ss
 popw %es
 xorl %eax, %eax
 movl %eax, 0x44(%bp)
 movw 0x0e(%bp), %ax
 addl 0x1c(%bp), %eax
 movl %eax, 0x48(%bp)
 movl %eax, 0x4c(%bp)
 movl 0x10(%bp), %eax
 mull 0x24(%bp)
 addl %eax, 0x4c(%bp)
 movl 0x2c(%bp), %eax
1:
 pushl %eax
 call cluster_to_lba_32
 movw $(msg_BootError_32 - Entry_32 + 0x7c00), %si
 jc boot_error_32
2:
 lesw (loadseg_off_32 - Entry_32)(%bp), %bx
 call readDisk_32
 xorw %di, %di
3:
 movw $11, %cx
 movw $(filename_32 - Entry_32 + 0x7c00), %si
 repz cmpsb
 jz 1f
 addw $0x20, %di
 andw $-0x20, %di
 cmp 0x0b(%bp), %di
 jnz 3b
 decw %dx
 jnz 2b
 popl %eax
 call next_cluster_32
 jmp 1b
1:
 pushw %es:(0x14-11)(%di)
 pushw %es:(0x1a-11)(%di)
 popl %eax
 xorw %bx, %bx
2:
 pushl %eax
 call cluster_to_lba_32
 jnc 1f
 movw 0x40(%bp), %dx
 ljmp *(loadseg_off_32 - Entry_32)(%bp)
1:
 call readDisk_32
 decw %dx
 jnz 1b
 popl %eax
 call next_cluster_32
 jmp 2b
# 1768 "grldrstart.S"
next_cluster_32:
 pushw %es
 pushw %bx
 shll $2, %eax
 movzwl 0x0b(%bp), %ebx
 divl %ebx
# 1795 "grldrstart.S"
 addl 0x48(%bp), %eax
 movw $0x0060, %bx
 movw %bx, %es
 xorw %bx, %bx
 cmpl 0x44(%bp), %eax
 jz 1f
 movl %eax, 0x44(%bp)
 call readDisk_32
1:
 addr32 andb $0x0f, %es:3(%edx)
 addr32 movl %es:(%edx), %eax
 popw %bx
 popw %es
 ret
# 1831 "grldrstart.S"
cluster_to_lba_32:
 cmpl $0x0ffffff8, %eax
 cmc
 jb 1f
 decl %eax
 decl %eax
 movzbl 0x0d(%bp), %edx
 pushw %dx
 mull %edx
 popw %dx
 addl 0x4c(%bp), %eax
1:
 ret
# 1857 "grldrstart.S"
readDisk_32:
 pushal
 xorl %edx, %edx
 pushl %edx
 pushl %eax
 pushw %es
 pushw %bx
 pushw $1
 pushw $16
 xorl %ecx, %ecx
 pushl 0x18(%bp)
 popw %cx
 divl %ecx
 incw %dx
 popw %cx
 pushw %dx
 xorw %dx, %dx
 divl %ecx
 xchgb %dl, %dh
 popw %cx
 xchgb %al, %ch
 shlb $6, %ah
 orb %ah, %cl
 movw $0x201, %ax
ebios_32:
 movw %sp, %si
 movb 0x40(%bp), %dl
 pushw %es
 pushw %ds
 int $0x13
 popw %ds
 popw %es
 popaw
 popal
 jc disk_error_32
 incl %eax
 addw 0x0b(%bp), %bx
 jnc 1f
 pushw %dx
 movw %es, %dx
 addb $0x10, %dh
 movw %dx, %es
 popw %dx
1:
 ret
msg_DiskReadError_32:
 .ascii "disk error\0"
msg_BootError_32:
 .ascii "No "
filename_32:
 .ascii "GRLDR      \0"
filename_end_32:
 . = Entry_32 + 0x1e8
loadseg_off_32:
 .word 0
 .word 0x2000
 . = Entry_32 + 0x1ec
boot_image_ofs_32:
 .word (filename_32 - Entry_32)+(filename_end_32 - filename_32 - 1)*2048
 . = Entry_32 + 0x1ee
disk_error_32:
 movw $(msg_DiskReadError_32 - Entry_32 + 0x7c00), %si
boot_error_32:
1:
 lodsb (%si), %al
 movb $0x0e, %ah
 int $0x10
 cmpb $0, %al
 jne 1b
1: jmp 1b
 . = Entry_32 + 0x1fc
 .word 0, 0xAA55
 . = Entry_32 + 0x200
 . = _start1 + 0x600
 .arch i186, nojumps
# 2067 "grldrstart.S"
Entry_12_16:
 jmp 1f
 . = Entry_12_16 + 0x02
# 2091 "grldrstart.S"
 .byte 0x90
 . = Entry_12_16 + 0x03
 .ascii "GRLDR   "
 . = Entry_12_16 + 0x0b
 .word 0x200
 . = Entry_12_16 + 0x0d
 .byte 1
 . = Entry_12_16 + 0x0e
 .word 1
 . = Entry_12_16 + 0x10
 .byte 2
 . = Entry_12_16 + 0x11
 .word 224
 . = Entry_12_16 + 0x13
 .word 2880
 . = Entry_12_16 + 0x15
 .byte 0xf0
 . = Entry_12_16 + 0x16
 .word 9
 . = Entry_12_16 + 0x18
 .word 18
 . = Entry_12_16 + 0x1a
 .word 2
 . = Entry_12_16 + 0x1c
 .long 0
 . = Entry_12_16 + 0x20
 .long 0
 . = Entry_12_16 + 0x24
# 2157 "grldrstart.S"
 .byte 0
 . = Entry_12_16 + 0x25
 .byte 0
 . = Entry_12_16 + 0x26
 .byte 0x29
 . = Entry_12_16 + 0x27
 .long 0x0AC4AF63
 . = Entry_12_16 + 0x2b
 .ascii "NO NAME    "
 . = Entry_12_16 + 0x36
 .ascii "FAT12   "
# 2226 "grldrstart.S"
 . = Entry_12_16 + 0x3e
1:
 cli
 cld
 . = Entry_12_16 + 0x40
 movb $0xff, %dh
 cmpb $0xff, %dh
 jne 1f
 movb $0, %dl
1:
 xorw %ax, %ax
 movw $0x7c00, %bp
 movw %ax, %ss
 leaw -0x20(%bp), %sp
 sti
 movw %dx, 0x24(%bp)
 pushaw
 movb $0x41, %ah
 movw $0x55AA, %bx
 pushw %dx
 int $0x13
 popw %dx
 pushw %ss
 popw %ds
 jc 1f
 cmpw $0xAA55, %bx
 jne 1f
 testb $1, %cl
 jz 1f
 testb %dl, %dl
 jns 1f
 movb $0x42, (ebios_12_16 - 1 - Entry_12_16 + 0x7c00)
1:
 popaw
 movw %ax, %es
# 2323 "grldrstart.S"
1:
# 2357 "grldrstart.S"
 movw 0x1c(%bp), %si
 movw 0x1e(%bp), %di
 addw 0x0e(%bp), %si
 adcw %ax, %di
 movw %si, 0x28(%bp)
 movw %di, 0x2a(%bp)
 movb 0x10(%bp), %al
 mulw 0x16(%bp)
 addw %ax, %si
 adcw %dx, %di
 movw %si, 0x2c(%bp)
 movw %di, 0x2e(%bp)
 movw 0x0b(%bp), %bx
 movb $5, %cl
 shrw %cl, %bx
 movw 0x11(%bp), %ax
 addw %bx, %ax
 decw %ax
 divw %bx
 cwd
 movw %ax, 0x26(%bp)
 addw %ax, %si
 adcw %dx, %di
 movw %si, 0x30(%bp)
 movw %di, 0x32(%bp)
 . = . - (. - 1b)/63
# 2421 "grldrstart.S"
 movw $0xffff, 0x36(%bp)
 movw 0x16(%bp), %ax
 mulw 0x0b(%bp)
 jc 1f
 movw %ax, 0x36(%bp)
1:
# 2436 "grldrstart.S"
 movw 0x2c(%bp), %ax
 movw 0x2e(%bp), %dx
 movw 0x26(%bp), %cx
 lesw (loadseg_off_12_16 - Entry_12_16)(%bp), %bx
 call readDisk_12_16
 lesw (loadseg_off_12_16 - Entry_12_16)(%bp), %di
# 2457 "grldrstart.S"
1:
 movw $(filename_12_16 - Entry_12_16 + 0x7c00), %si
 movb $11, %cl
 pushw %di
 repz cmpsb
 popw %di
 jz 1f
 addw $0x20, %di
 jz 2f
 cmpb %ch, %es:(%di)
 jnz 1b
2:
 movw $(msg_BootError_12_16 - Entry_12_16 + 0x7c00), %si
 jmp boot_error_12_16
1:
 ######################################################################
 # Reads the FAT chain and stores it in a temporary buffer in the
 # first 64KB. The FAT chain is stored an array of 16-bit cluster
 # numbers, ending with 0.
 # The file must fit in conventional memory, so it can't be larger
 # than 640KB. The sector size must be at least 512 bytes, so the
 # FAT chain can't be larger than around 3KB.
 ######################################################################
 pushw %es:0x1a(%di)
 movw 0x16(%bp), %cx
 movw 0x28(%bp), %ax
 movw 0x2a(%bp), %dx
 pushw %es
 call readDisk_12_16
 popw %ds
 popw %ax
 pushw %ds
 pushw %ss
 popw %es
 movw $0x2000, %di
2:
 stosw
 movw %ax, %si
 popw %dx
 pushw %dx
 addw %si, %si
 jnc 1f
 addb $0x10, %dh
1:
 cmpw $0x1801, 0x36(%bp)
 jnb 3f
 addw %ax, %si
 shrw $1, %si
 lodsw
 jnc 1f
 movb $4, %cl
 shrw %cl, %ax
1:
 andb $0x0f, %ah
 cmpw $0x0ff7, %ax
 jmp 4f
3:
 movw %dx, %ds
 lodsw
 cmpw $0xfff7, %ax
4:
 jbe 2b
 xorw %ax, %ax
 stosw
 popw %es
 pushw %ss
 popw %ds
 movw $0x2000, %si
1:
 lodsw
 subw $2, %ax
 jc 1f
 movb 0x0d(%bp), %cl
 mulw %cx
 addw 0x30(%bp), %ax
 adcw 0x32(%bp), %dx
 call readDisk_12_16
 jmp 1b
1:
 movw 0x24(%bp), %dx
 ljmp *(loadseg_off_12_16 - Entry_12_16)(%bp)
# 2646 "grldrstart.S"
readDisk_12_16:
2:
 pushfw
 pushaw
 xorw %cx, %cx
 pushw %cx
 pushw %cx
 pushw %dx
 pushw %ax
 pushw %es
 pushw %bx
 incw %cx
 pushw %cx
 movb $16, %cl
 pushw %cx
 xchgw %ax, %cx
# 2673 "grldrstart.S"
 pushw %bx
 pushw %dx
 movw 0x18(%bp), %ax
 movw %ax, %bx
 mulw 0x1a(%bp)
 xchgw %ax, %cx
 popw %dx
# 2698 "grldrstart.S"
 divw %cx
 xchgw %ax, %dx
 divb %bl
 xchgb %al, %ah
 incw %ax
 xchgw %ax, %dx
 xchgw %ax, %cx
 xchgb %cl, %ch
 rorb $1, %cl
 rorb $1, %cl
 orb %dl, %cl
# 2728 "grldrstart.S"
 popw %bx
 movw $0x0201, %ax
ebios_12_16:
 movw %sp, %si
 movb 0x24(%bp), %dl
 pushw %es
 pushw %ds
 int $0x13
 popw %ds
jc_code_begin:
 jc disk_error_12_16
jc_code_end:
 popw %bx
 leaw 0x20(%bx), %bx
 movw %bx, %es
 popaw
 popaw
 popfw
 incw %ax
 jnz 1f
 incw %dx
1:
 loop 2b
 ret
msg_DiskReadError_12_16:
 .ascii "disk error\0"
msg_BootError_12_16:
 .ascii "No "
filename_12_16:
 .ascii "GRLDR      \0"
filename_end_12_16:
 . = Entry_12_16 + 0x1e8
loadseg_off_12_16: .word 0
loadseg_seg_12_16: .word 0x2000
 . = Entry_12_16 + 0x1ec
boot_image_ofs_12_16:
 .word (filename_12_16 - Entry_12_16)+(filename_end_12_16 - filename_12_16 - 1)*2048
 . = Entry_12_16 + 0x1ee
disk_error_12_16:
 movw $(msg_DiskReadError_12_16 - Entry_12_16 + 0x7c00), %si
boot_error_12_16:
1:
 lodsb (%si), %al
 movb $0x0e, %ah
 int $0x10
 cmpb $0, %al
 jne 1b
1: jmp 1b
 . = Entry_12_16 + 0x1fc
 .word 0, 0xAA55
 . = Entry_12_16 + 0x200
 . = _start1 + 0x800
 .arch i486, nojumps
# 2842 "grldrstart.S"
Entry_ext2:
 jmp 1f
 . = Entry_ext2 + 0x02
# 2867 "grldrstart.S"
 .byte 0x02
 . = Entry_ext2 + 0x03
msg_DiskReadError_ext2:
 .ascii "I/O error\0"
 . = Entry_ext2 + 0x0d
 .byte 2
 . = Entry_ext2 + 0x0e
 .word 1024
 . = Entry_ext2 + 0x10
 .long 0x10000
 . = Entry_ext2 + 0x14
 .long 0x100
 . = Entry_ext2 + 0x18
 .word 18
 . = Entry_ext2 + 0x1a
 .word 2
 . = Entry_ext2 + 0x1c
 .long 0
 . = Entry_ext2 + 0x20
# 2945 "grldrstart.S"
 .long 2880
 . = Entry_ext2 + 0x24
 .byte 0
 . = Entry_ext2 + 0x25
 .byte 0xff
 . = Entry_ext2 + 0x26
 .word 0x80
 . = Entry_ext2 + 0x28
 .long 2048
 . = Entry_ext2 + 0x2c
# 2984 "grldrstart.S"
 .long 2
 . = Entry_ext2 + 0x30
1:
 cld
 xorw %ax, %ax
 nop
 movw %ax, %ss
 movw $0x7c00, %sp
 movw %sp, %bp
 pushw %ax
 movw $0x1000, %bx
 pushw %bx
 pushw %ax
# 3014 "grldrstart.S"
 movb %dl, 0x24(%bp)
 pushw %ss
 movb $0x41, %ah
 movw $0x55AA, %bx
 int $0x13
 popw %ds
 jc 1f #; No EBIOS
 .byte 0xD0, 0xD9 #; ror cl: D0 C9
 jnc 1f #; No EBIOS
 movb $0x42, (ebios_ext2 - 1 - Entry_ext2 + 0x7c00)
1:
 xorl %eax, %eax
# 3046 "grldrstart.S"
 movb $2, %al
4:
# 3065 "grldrstart.S"
 pushw %di
 pushw %ss
 pushfw
 decl %eax
 cdq
 divl 0x28(%bp)
 pushl %edx
 cdq
 shll $5, %eax
 divl 0x0e(%bp)
 pushw %dx
 addl 0x2c(%bp), %eax
 call read_block
 popw %si
 popl %eax
 movw 0x26(%bp), %dx
 mull %edx
 divl 0x0e(%bp)
 pushw %dx
 addl 8(%bx, %si), %eax
 call read_block
 popw %si
 addw %bx, %si
# 3146 "grldrstart.S"
 pushw %ss
 popw %es
 leaw -0x58(%bx), %di
 movb $0x2c, %cl
 repz movsw
 movl %ecx, (0x0c - 0x58)(%di)
 movl (0x04 - 0x58)(%di), %eax
 decl %eax
 divl 0x0e(%bp)
 incl %eax
 movl %eax, (0x08 - 0x58)(%di)
# 3176 "grldrstart.S"
 lodsl
 testl %eax, %eax
 jz 1f
 movb $0x80, %bh
 call read_block_c
 lodsl
 testl %eax, %eax
 jz 1f
# 3206 "grldrstart.S"
 movb $0xc0, %bh
 call read_block_c
 lodsl
 testl %eax, %eax
 jz 1f
 call read_block
1:
 movl (0x0c - 0x58)(%di), %ebx
 subl $12, %ebx
 jc 3f
 pushw %bx
 subl 0x14(%bp), %ebx
 popw %ax
 jnc 2f
 addb $(0x70 / 4), %ah
 jmp 8f
2:
 pushl %ebx
 subl 0x10(%bp), %ebx
 jc 7f
 popl %eax
 xchgl %eax, %ebx
 divl 0x10(%bp)
 pushl %edx
 testl %edx, %edx
 jnz 7f
 shlw $2, %ax
 xchgw %ax, %bx
 movl (%bx, %di), %eax
 movw $0xc000, %bx
 call read_block_c
7:
 popl %eax
 cdq
 divl 0x14(%bp)
 pushw %dx
 testw %dx, %dx
 jnz 7f
 shlw $2, %ax
 xchgw %ax, %bx
 movl 0xb000(%bx, %di), %eax
 movw $0x8000, %bx
 call read_block_c
7:
 popw %ax
8:
 xchgw %ax, %bx
3:
 shlw $2, %bx
 movl (%bx, %di), %eax
# 3335 "grldrstart.S"
 popfw
 popw %bx
 popw %es
 pushfw
 call read_block
 popfw
 pushw %es
 pushw %bx
 pushfw
 jc 3f
 xorw %si, %si
 pushw %ss
 popw %es
2:
 pushw %ds
 movw %di, %ds
 movw $(filename_ext2 - Entry_ext2 + 0x7c00), %di
 pushw %si
 lodsl
 pushl %eax
 lodsw
 xchgw %ax, %dx
 lodsw
 decb %ah
 xchgw %ax, %cx
 repz cmpsb
 jnz 5f
 xchgw %ax, %cx
 scasb
5:
 popl %eax
 popw %si
 movw %ds, %di
 popw %ds
 stc
 jz 4b
 addw %dx, %si
 cmpw 0x0e(%bp), %si
 jb 2b
3:
 incl (0x0c - 0x58)(%di)
 decl (0x08 - 0x58)(%di)
 jnz 1b
# 3429 "grldrstart.S"
 movw $(msg_No_grldr_ext2 - Entry_ext2 + 0x7c00), %si
 jnc boot_error_ext2
# 3441 "grldrstart.S"
 movw 0x24(%bp), %dx
 pushw %di
 pushw %ss
 lret
read_block_c:
 pushw %ss
 popw %es
 stc
# 3469 "grldrstart.S"
read_block:
 jc 1f
 .byte 0xC4, 0x5E, 0xFC
 jnz 1f
 .byte 0xC4, 0x5E, 0xFA
1:
 movzbl 0x0d(%bp), %ecx
 . = . - (. - 1b) / 6
  mull %ecx
 . = . - (. - 1b) / 9
 addl 0x1c(%bp), %eax
# 3511 "grldrstart.S"
readDisk_ext2:
2:
 pushal
 pushl %edx
 pushl %eax
 pushw %es
 pushw %bx
 pushw $1
 pushw $16
 pushl 0x18(%bp)
 popw %cx
 divl %ecx
 incw %dx
 popw %cx
 pushw %dx
 xorw %dx, %dx
 divl %ecx
 xchgb %dl, %dh
 popw %cx
 xchgb %al, %ch
 shlb $6, %ah
 orb %ah, %cl
 incw %ax
# 3559 "grldrstart.S"
 movb $0x02, %ah
ebios_ext2:
 movw %sp, %si
 movb 0x24(%bp), %dl
 pushw %es
 pushw %ds
 int $0x13
 popw %ds
 popw %bx
 jc disk_error_ext2
 leaw 0x20(%bx), %bx
 movw %bx, %es
 popaw
 popal
 incl %eax
 loop 2b
 ret
msg_No_grldr_ext2:
 .ascii "No "
filename_ext2:
 .ascii "grldr\0"
 . = Entry_ext2 + 0x1ee
filename_end_ext2:
 .word (filename_ext2 - Entry_ext2)+(filename_end_ext2 - filename_ext2 - 1)*2048
 . = Entry_ext2 + 0x1f0
disk_error_ext2:
 movw $(msg_DiskReadError_ext2 - Entry_ext2 + 0x7c00), %si
boot_error_ext2:
1:
 lodsb (%si), %al
 movb $0x0e, %ah
 int $0x10
 cmpb $0, %al
 jne 1b
1: jmp 1b
# 3638 "grldrstart.S"
 . = Entry_ext2 + 0x1fe
 .word 0xAA55
 . = _start1 + 0xA00
# 3762 "grldrstart.S"
 .arch i586
Entry_nt:
 jmp 1f
 . = Entry_nt + 0x02
 .byte 0x90
 .ascii "NTFS    "
 .word 0
 .byte 0
 .word 0
 .byte 0
 .word 0
 .word 0
 .byte 0xF8
 .word 0
 .word 255
 .word 63
nt_part_ofs:
 .long 0
 .long 0
 .long 0x800080
 .long 0,0
 .long 0,0
 .long 0,0
 .long 0
 .long 4
 .long 0,0
 .long 0
1:
 . = Entry_nt + 0x54
 cli
 cld
 . = Entry_nt + 0x56
 movb $0xff, %dh
 xorw %ax, %ax
 movw $0x7c00, %bp
 movw %ax, %ss
 leaw -0x20(%bp), %sp
 sti
 movw %dx, -2(%bp)
 pushw %ax
 movb $0x41, %ah
 movw $0x55AA, %bx
 int $0x13
 popw %ds
 jc 1f
 cmpw $0xAA55, %bx
 jne 1f
 testb $1, %cl
 jz 1f
 movb $0x42, (ebios_nt - 1 - Entry_nt)(%bp)
1:
 pushw %ss
 popw %es
 cmpl $0x42555247, (nt_sector_mark - Entry_nt)(%bp)
 jz 1f
 movw $0x7E00, %bx
 movl (nt_part_ofs - Entry_nt)(%bp), %eax
 incl %eax
 call readDisk_nt
 call readDisk_nt
 call readDisk_nt
1:
 xorl %eax, %eax
 movw 0xb(%bp), %ax
 movw %ax, -4(%bp)
 call convert_to_power_2
 movb %cl, %bl
 movb 0xd(%bp), %al
 call convert_to_power_2
 movb %cl, %ch
 addb %bl, %ch
 subb $9, %ch
 movb %ch, -5(%bp)
 movb 0x44(%bp), %al
 call convert_size
 cmpb $3, %cl
 jbe 1f
NTFS_Large_Structure_Error:
 movb $1, %al
 jmp NTFS_Error
1:
 movb %cl, -7(%bp)
 movb 0x40(%bp), %al
 call convert_size
 cmpb $1, %cl
 jnz NTFS_Large_Structure_Error
 movb %cl, -6(%bp)
 movl 0x30(%bp), %eax
 movb %ch, %cl
 shll %cl, %eax
 addl (nt_part_ofs - Entry_nt)(%bp), %eax
 movl %eax, -12(%bp)
 movw $1, %dx
 movb -6(%bp), %cl
 shlw %cl, %dx
 movw %dx, %cx
 movw $0x2000, %bx
 pushw %bx
1:
 call readDisk_nt
 loop 1b
 popw %bx
 cmpw $0x4946, (%bx)
 jnz NTFS_Corrupt_Error
 movw %dx, %cx
 call ntfs_fixup
 movw %bx, %di
 movb $0x80, %al
 call ntfs_locate_attr
 jc NTFS_Corrupt_Error
 movw $(0x2000 + 6144), %bx
 xorl %eax, %eax
 movb $0x5, %al
 call ntfs_read_mft
 movw %bx, %di
 jmp ntfs_search
convert_size:
 orb %al, %al
 js 1f
 movb %ch, %cl
 jmp 2f
1:
 negb %al
 subb $9, %al
 movb %al, %cl
 ret
# 3961 "grldrstart.S"
convert_to_power_2:
 xorb %cl, %cl
2:
 incb %cl
 shrl $1, %eax
 jnc 2b
 decb %cl
 ret
ntfs_fixup:
 push %bx
 push %di
 movw %bx, %di
 movw 6(%bx), %ax
 decw %ax
 movw %ax, %bx
 mulw -4(%bp)
 shlw $9, %cx
 cmpw %ax, %cx
 jnz NTFS_Corrupt_Error
 movw %bx, %cx
 movw %di, %bx
 addw 4(%bx), %bx
 movw (%bx), %ax
 subw $2, %di
1:
 addw -4(%bp), %di
 addw $2, %bx
 cmpw (%di), %ax
 jnz NTFS_Corrupt_Error
 movw (%bx), %dx
 movw %dx, (%di)
 loop 1b
 popw %di
 popw %bx
 ret
NTFS_Corrupt_Error:
 movb $2, %al
 jmp NTFS_Error
# 4022 "grldrstart.S"
readDisk_nt:
 pushal
 xorl %edx, %edx
 pushl %edx
 pushl %eax
 pushw %es
 pushw %bx
 pushw $1
 pushw $16
 xorl %ecx, %ecx
 pushl 0x18(%bp)
 popw %cx
 divl %ecx
 incw %dx
 popw %cx
 pushw %dx
 xorw %dx, %dx
 divl %ecx
 xchgb %dl, %dh
 popw %cx
 xchgb %al, %ch
 shlb $6, %ah
 orb %ah, %cl
 movw $0x201, %ax
ebios_nt:
 movw %sp, %si
 movb -2(%bp), %dl
 int $0x13
 popaw
 popal
 jc disk_error_nt
 incl %eax
 addw 0x0b(%bp), %bx
 jnc 1f
 pushw %dx
 movw %es, %dx
 addb $0x10, %dh
 movw %dx, %es
 popw %dx
1:
 ret
msg_DiskReadError_nt:
 .ascii "0\0"
NTFS_Error:
 addb %al, (msg_DiskReadError_nt - Entry_nt)(%bp)
 jmp disk_error_nt
msg_NTFS_Not_Found_Error:
 .ascii "No "
nt_boot_image:
 .ascii "grldr\0"
 . = Entry_nt + 0x1e8
nt_boot_image_end:
nt_loadseg_off:
 .word 0
 .word 0x2000
 . = Entry_nt + 0x1ec
nt_boot_image_ofs:
 .word (nt_boot_image - Entry_nt)+(nt_boot_image_end - nt_boot_image-1)*2048
 . = Entry_nt + 0x1ee
disk_error_nt:
 movw $(msg_DiskReadError_nt - Entry_nt + 0x7c00), %si
boot_error_nt:
1:
 lodsb (%si), %al
 movb $0x0e, %ah
 int $0x10
 cmpb $0, %al
 jne 1b
1: jmp 1b
 . = Entry_nt + 0x1fc
 .word 0, 0xAA55
ntfs_search:
 call ntfs_init_attr
 movb $0x90, %al
1:
 call ntfs_find_attr
 jc NTFS_Not_Found_Error
 cmpl $0x180400, 8(%si)
 jnz 1b
 addw 0x14(%si), %si
 cmpb $0x30, (%si)
 jnz 1b
 addw $0x10, %si
 addw (%si), %si
 call ntfs_find_grldr
 jnc ntfs_final
 call ntfs_init_attr
 movb $0xB0, %al
1:
 call ntfs_find_attr
 jc NTFS_Not_Found_Error
 movw 9(%si), %bx
 cmpb $4, %bl
 jnz 1b
 cmpb $0, 8(%si)
 jnz 1f
 pushw 0x10(%si)
 addw 0x14(%si), %si
 pushw %si
 jmp 2f
1:
 pushw 0x30(%si)
 xorl %edx, %edx
 movl 0x28(%si), %ecx
 cmpw $4096, %cx
 ja NTFS_Not_Found_Error
 shrl $9, %ecx
 movw $(((0x2000 + 6144) + 6144) + 4096), %bx
 pushw %bx
 call ntfs_read_data
2:
 movb $0xA0, %al
1:
 call ntfs_locate_attr
 jc NTFS_Not_Found_Error
 cmpl $0x400401, 8(%si)
 jnz 1b
 movb -7(%bp), %cl
 xorl %ebx, %ebx
 movb $1, %bl
 shll %cl, %ebx
 xorl %edx, %edx
 popw %si
 popw %cx
1:
 pushw %cx
 lodsb (%si), %al
 movw $8, %cx
2:
 pushw %cx
 pushw %ax
 testb $1, %al
 jz 3f
 pushw %si
 pushl %edx
 pushl %ebx
 movl %ebx, %ecx
 movw $((0x2000 + 6144) + 6144), %bx
 call ntfs_read_attr
 jc NTFS_Not_Found_Error
 cmpw $0x4E49, (%bx)
 jnz NTFS_Not_Found_Error
 call ntfs_fixup
 movw %bx, %si
 addw $0x18, %si
 addw (%si), %si
 call ntfs_find_grldr
 jnc ntfs_final_0
 popl %ebx
 popl %edx
 popw %si
3:
 addl %ebx, %edx
 popw %ax
 shrb $1, %al
 popw %cx
 loop 2b
 popw %cx
 loop 1b
NTFS_Not_Found_Error:
 leaw (msg_NTFS_Not_Found_Error - Entry_nt)(%bp), %si
 jmp boot_error_nt
ntfs_final_0:
ntfs_final:
 cmpw $0, 4(%si)
 jnz NTFS_Large_Structure_Error
 movl (%si), %eax
 movw %di, %bx
 call ntfs_read_mft
 movb $0x80, %al
 call ntfs_locate_attr
 jc NTFS_No_Data_Error
 cmpb $1, 8(%si)
 jz 1f
 movw 0x10(%si), %cx
 lesw (nt_loadseg_off - Entry_nt)(%bp), %di
 addw 0x14(%si), %si
 rep movsb (%si), %es:(%di)
 jmp 2f
1:
 xorl %edx, %edx
 movl 0x28(%si), %ecx
 shrl $9, %ecx
 lesw (nt_loadseg_off - Entry_nt)(%bp), %bx
 call ntfs_read_data
2:
 movw -2(%bp), %dx
 ljmp *(nt_loadseg_off - Entry_nt)(%bp)
NTFS_No_Data_Error:
 movb $4, %al
 jmp NTFS_Error
ntfs_find_grldr:
 movw %si, %bx
 testb $2, 0xC(%bx)
 jz 1f
 stc
 ret
1:
 xorb %ch, %ch
 pushw %si
 leaw (nt_boot_image - Entry_nt)(%bp), %si
 addw $0x52, %bx
 movb -2(%bx), %cl
1:
 lodsb (%si), %al
 movb (%bx), %ah
 cmpb $'A', %ah
 jb 2f
 cmpb $'Z', %ah
 ja 2f
 addb $('a'-'A'), %ah
2:
 cmpb %ah, %al
 jnz 3f
 incw %bx
 incw %bx
 loop 1b
 cmpb $0,(%si)
 jnz 3f
 popw %si
 clc
 ret
3:
 popw %si
 addw 8(%si), %si
 jmp ntfs_find_grldr
ntfs_locate_attr:
 call ntfs_init_attr
 call ntfs_find_attr
 jc 1f
2:
 testb $4, (%di)
 jnz 2f
 call ntfs_find_attr
 jnc 2b
 call ntfs_init_attr
 call ntfs_find_attr
2:
 clc
1:
 ret
ntfs_init_attr:
 pushw %ax
 xorw %ax, %ax
 movw %ax, (%di)
 movw %ax, 6(%di)
 movw 0x14(%di), %ax
 addw %di, %ax
 movw %ax, 4(%di)
 popw %ax
 cmpw $0x2000, %di
 jnz 1f
 orb $2, (%di)
1:
 ret
# 4426 "grldrstart.S"
ntfs_find_attr:
 movw 4(%di), %bx
 testb $4, (%di)
 jnz 6f
1:
 movw %bx, %si
 cmpb $0xFF, (%si)
 jz 3f
 cmpb $0x20, (%si)
 jnz 2f
 movw %si, 6(%di)
2:
 addw 4(%bx), %bx
 cmpb %al, (%si)
 jnz 1b
 movw %bx, 4(%di)
 movw %si, 2(%di)
2:
 ret
3:
 cmpw $1, 6(%di)
 jb 2b
 movw 6(%di), %si
 cmpb $0, 8(%si)
 jnz 4f
 movw %si, %bx
 addw 0x14(%bx), %bx
 addw 4(%si), %si
 jmp 5f
4:
 movl 0x28(%si), %ecx
 shrl $9, %ecx
 cmpw $8, %cx
 ja NTFS_Corrupt_Error
 leaw 2048(%di), %bx
 pushw %ax
 xorl %edx, %edx
 call ntfs_read_data
 popw %ax
 jc 2b
 movw 0x30(%si), %si
 addw %bx, %si
5:
 movw %si, 6(%di)
 orb $4, (%di)
 testb $2, (%di)
 jz 6f
 call ntfs_fix_mmft
6:
 movw %bx, %si
 cmpw 6(%di), %bx
 jb 1f
7:
 stc
 ret
1:
 addw 4(%bx), %bx
 cmpb %al, (%si)
 jnz 6b
 pushw %ax
 pushw %es
 pushw %ds
 popw %es
 movw %si, 2(%di)
 movw %bx, 4(%di)
 movl 0x10(%si), %eax
 leaw 1024(%di), %bx
 testb $2, (%di)
 jnz 2f
 call ntfs_read_mft
 jmp 3f
2:
 pushw %bx
 call readDisk_nt
 movl 0x14(%si), %eax
 call readDisk_nt
 popw %bx
 cmpw $0x4946, (%bx)
 jnz NTFS_Corrupt_Error
 movw $2, %cx
 call ntfs_fixup
3:
 popw %es
 popw %ax
 addw 0x14(%bx), %bx
4:
 cmpb $0xFF, (%bx)
 jz 7b
 cmpb %al, (%bx)
 jz 5f
 addw 4(%bx), %bx
 jmp 4b
5:
 movw %bx, %si
 ret
ntfs_fix_mmft:
 pushw %ax
 orb $8, (%di)
1:
 cmpw 6(%di), %bx
 jae NTFS_Corrupt_Error
 cmpb %al, (%bx)
 jz 2f
 addw 4(%bx), %bx
 jmp 1b
2:
 movw %bx, 2(%di)
 movl -12(%bp), %eax
 movl %eax, 0x10(%bx)
 incl %eax
 movl %eax, 0x14(%bx)
1:
 addw 4(%bx), %bx
 cmpw 6(%di), %bx
 jae 2f
 cmpb $0x80, (%bx)
 jnz 2f
 movl 0x10(%bx), %edx
 movb -6(%bp), %cl
 shll %cl, %edx
 call ntfs_read_attr
 orl %eax, %eax
 jz NTFS_Corrupt_Error
 movl %eax, 0x10(%bx)
 movl %edx, 0x14(%bx)
 jmp 1b
2:
 movw 2(%di), %bx
 andb $(~8), (%di)
 popw %ax
 ret
ntfs_read_mft:
 pushw %di
 movw $0x2000, %di
 movb -6(%bp), %cl
 shll %cl, %eax
 movl %eax, %edx
 movl $1, %eax
 shll %cl, %eax
 movl %eax, %ecx
 call ntfs_read_attr
 jc NTFS_Corrupt_Error
 cmpw $0x4946, (%bx)
 jnz NTFS_Corrupt_Error
 call ntfs_fixup
 popw %di
 ret
# 4602 "grldrstart.S"
ntfs_read_attr:
 pushw 2(%di)
 pushl %edx
 pushl %ecx
 pushw %bx
 movw 2(%di), %si
 movb (%si), %al
 testb $4, (%di)
 jz 2f
 movw %si, %bx
 movb -5(%bp), %cl
 shrl %cl, %edx
1:
 cmpw 6(%di), %bx
 jae 2f
 cmpb %al, (%bx)
 jnz 2f
 cmpl %edx, 8(%bx)
 ja 2f
 movw %bx, %si
 addw 4(%bx), %bx
 jmp 1b
2:
 movw %si, 4(%di)
 call ntfs_find_attr
 popw %bx
 popl %ecx
 popl %edx
 jc 1f
 call ntfs_read_data
 clc
1:
 popw 2(%di)
 ret
# 4649 "grldrstart.S"
ntfs_read_data:
 pushw %cx
 pushw %bx
 testb $1, 8(%si)
 jz NTFS_Corrupt_Error
 movb 0xC(%si), %al
 andb $1, %al
 orb %al, (%di)
 movl %ecx, 0x1C(%di)
 movb -5(%bp), %cl
 movl %edx, %eax
 shrl %cl, %eax
 movl %eax, 0x18(%di)
 shll %cl, %eax
 subl %eax, %edx
 movl %edx, 0x20(%di)
 xorw %dx, %dx
 movl %edx, 0x10(%di)
 movl 0x10(%si), %edx
 addw 0x20(%si), %si
1:
 call ntfs_runlist_read_block
 cmpl 0x18(%di), %edx
 jbe 1b
1:
 movb -5(%bp), %cl
 orl %eax, %eax
 jz 2f
 movl 0x18(%di), %eax
 subl 8(%di), %eax
 addl 0x10(%di), %eax
 shll %cl, %eax
 addl 0x20(%di), %eax
 testb $8, (%di)
 jz 3f
 pushl %eax
 incl %eax
 subl 8(%di), %edx
 addl 0x10(%di), %edx
 shll %cl, %edx
 cmpl %eax, %edx
 jnz 4f
 pushw %cx
 call ntfs_runlist_read_block
 popw %cx
 movl 0x10(%di), %eax
 shll %cl, %eax
4:
 movl %eax, %edx
 popl %eax
 addl (nt_part_ofs - Entry_nt)(%bp), %edx
3:
 addl (nt_part_ofs - Entry_nt)(%bp), %eax
2:
 testb $8, (%di)
 jnz 1f
 pushl %ebx
 movl %edx, %ebx
 subl 0x18(%di), %ebx
 shll %cl, %ebx
 movl %ebx, %ecx
 popl %ebx
 subl 0x20(%di), %ecx
 movl $0, 0x20(%di)
 cmpl 0x1C(%di), %ecx
 jbe 2f
 movl 0x1C(%di), %ecx
2:
 pushl %ecx
 orl %eax, %eax
 jnz 3f
 call ntfs_sparse_block
 jmp 4f
3:
 call readDisk_nt
 loop 3b
4:
 popl %ecx
 subl %ecx, 0x1C(%di)
 jbe 1f
 movl %edx, 0x18(%di)
 call ntfs_runlist_read_block
 jmp 1b
1:
 popw %bx
 popw %cx
 ret
# 4764 "grldrstart.S"
ntfs_runlist_read_data:
# 4784 "grldrstart.S"
 xorl %eax, %eax
 testb %cl, %cl
 jz 2f
 pushw %cx
1:
 lodsb (%si), %al
 rorl $8, %eax
 decb %cl
 jnz 1b
 popw %cx
 negb %cl
 add $4, %cl
 shlb $3, %cl
2:
 ret
NTFS_Run_Overflow_Error:
 movb $3, %al
 jmp NTFS_Error
ntfs_runlist_read_block:
 lodsb (%si), %al
 movb %al, %cl
 movb %cl, %ch
 andb $0xF, %cl
 jz 1f
 shrb $0x4, %ch
 call ntfs_runlist_read_data
 shrl %cl, %eax
 movl %edx, 8(%di)
 addl %eax, %edx
 movb %ch, %cl
 call ntfs_runlist_read_data
 sarl %cl, %eax
 addl %eax, 0x10(%di)
 ret
1:
 testb $4, (%di)
 jz NTFS_Run_Overflow_Error
 pushl %edx
 pushw %bx
 movw 2(%di), %si
 movb (%si), %al
 call ntfs_find_attr
 jc NTFS_Run_Overflow_Error
 cmpb $0, 8(%si)
 jz NTFS_Run_Overflow_Error
 movl $0, 0x10(%di)
 popw %bx
 popl %edx
 addw 0x20(%si), %si
 jmp ntfs_runlist_read_block
seg_to_lin:
 pushw %bp
 movw %sp, %bp
 xorl %eax, %eax
 xchgw 6(%bp), %ax
 shll $4, %eax
 addl 4(%bp), %eax
 popw %bp
 ret $4
lin_to_seg:
 pushw %bp
 movw %sp, %bp
 shll $12, 4(%bp)
 shrw $12, 4(%bp)
 popw %bp
 ret
fix_segs:
 pushw %ds
 pushw %si
 call seg_to_lin
 pushl %eax
 call lin_to_seg
 popw %si
 popw %ds
fix_es_di:
 pushw %es
 pushw %di
 call seg_to_lin
 pushl %eax
 call lin_to_seg
 popw %di
 popw %es
 ret
ntfs_sparse_block:
 pushw %di
 pushl %edx
 shll $9, %ecx
 testb $1, (%di)
 jz 2f
 xorl %edx, %edx
 movb 0x18(%di), %dl
 andb $0xF, %dl
 jz 2f
 movw %bx, %di
 pushw %cx
 movb -5(%bp), %cl
 addb $9, %cl
 shll %cl, %edx
 push %es
 push %di
 call seg_to_lin
 subl %edx, %eax
 movl $16, -16(%bp)
 shll %cl, -16(%bp)
 popw %cx
 addl %edx, %ecx
 subl -16(%bp), %ecx
 pushl %ecx
 call ntfs_decomp_block
 popl %ecx
 addl -16(%bp), %ecx
 jecxz 1f
 movw %di, %bx
2:
 movw %bx, %di
 movl %ecx, %edx
 xorl %eax, %eax
 movl %eax, %ecx
 call fix_es_di
3:
 movw $0x8000, %cx
 cmpl %edx, %ecx
 jbe 4f
 movw %dx, %cx
4:
 pushw %cx
 shrw $2, %cx
 rep stosl %eax, %es:(%di)
 call fix_es_di
 popw %cx
 subl %ecx, %edx
 jnz 3b
1:
 movw %di, %bx
 popl %edx
 popw %di
 ret
ntfs_decomp_block:
 pushw %ds
 pushw %si
 cld # added 2009-10-06 by tinybit
 pushl %eax
 call lin_to_seg
 popw %si
 popw %ds
 movl -16(%bp), %edx
 addl %edx, %eax
 pushl %eax
 call lin_to_seg
 popw %di
 popw %es
 pushw %es
 pushw %di
 pushw %ds
 pushw %si
 xorl %ecx, %ecx
1:
 movw $0x8000, %cx
 cmpl %edx, %ecx
 jbe 2f
 movw %dx, %cx
2:
 pushw %cx
 shrw $2, %cx
 rep movsl (%si), %es:(%di)
 call fix_segs
 popw %cx
 subl %ecx, %edx
 jnz 1b
 popw %di # Why these POPs should be in reverse order?
 popw %es # Seems a comment needed. -- tinybit
 popw %si #
 popw %ds #
1:
 xorl %edx, %edx
 lodsw (%si), %ax
 testb $0x80, %ah
 jnz 2f
 movw $0x800, %cx
 rep movsw (%si), %es:(%di)
 movw $0x1000, %dx
 jmp 7f
2:
 movw %ax, %cx
 andw $0xFFF, %cx
 incw %cx
 addw %si, %cx
 xorb %bh, %bh
3:
 cmpw $0x1000, %dx
 ja NTFS_Decompress_Error
 orb %bh, %bh
 jnz 4f
 lodsb (%si), %al
 movb %al, %bl
 movb $8, %bh
4:
 testb $1, %bl
 jz 5f
 movw %dx, %ax
 decw %ax
 pushw %cx
 pushw %bx
 movb $12, %cl
6:
 cmpw $0x10, %ax
 jb 6f
 shrw $1, %ax
 decb %cl
 jmp 6b
6:
 lodsw (%si), %ax
 movw %ax, %bx
 shrw %cl, %bx
 pushw %dx
 movw $1, %dx
 shlw %cl, %dx
 decw %dx
 andw %dx, %ax
 popw %dx
 addw $3, %ax
 movw %ax, %cx
 negw %bx
 decw %bx
6:
 movb %es:(%bx, %di), %al
 stosb %al, %es:(%di)
 incw %dx
 loop 6b
 popw %bx
 popw %cx
 jmp 4f
5:
 movsb (%si), %es:(%di)
 incw %dx
4:
 shrb $1, %bl
 decb %bh
 cmpw %cx, %si
 jb 3b
7:
 call fix_segs
 subl %edx, -16(%bp)
 jz 1f
 cmpw $0x1000, %dx
 je 1b
1:
 popw %si
 popw %ds
 ret
NTFS_Decompress_Error:
 pushw %ss
 popw %ds
 movb $5, %al
 jmp NTFS_Error
# 5171 "grldrstart.S"
 . = Entry_nt + 0x7fc
nt_sector_mark:
 .long 0x42555247
 . = _start1 + 0x1200
 .arch i586, jumps
# 5265 "grldrstart.S"
 .align 16
restore_GRLDR_CS:
2:
 call 1f
1:
 popw %bx # instruction pointer of 1b
 movw %cs, %ax
 shrw $4, %bx
 addw %ax, %bx # BX=segment value of this code
 pushw %bx
 pushw $(1f - 2b)
 lret
1:
 xorl %eax, %eax
 movw %bx, %ax
 shll $4, %eax
 addl $(gdt -2b), %eax
 movl %eax, %cs:(gdt - 2b + 2)
 movw $0x2000, %bx
 movw %bx, %es
 movw %ds, %bx # save old DS to BX
 cli
 lgdt %cs:(gdt - 2b)
 movl %cr0, %eax
 orb $1, %al
 movl %eax, %cr0
 movw $8, %si
 movw %si, %ds
 xorl %esi, %esi
 xorl %edi, %edi
 movl $(0x9000 / 4), %ecx
 cld
 repz movsl
 movw $16, %si
 movw %si, %ds
 andb $0xfe, %al
 movl %eax, %cr0
 movw %bx, %ds # restore DS from BX
 ljmp $0x2000, $(try_next_partition - _start1)
# Descriptor tables
# NOTE: The intel manual says gdt should be sixteen bytes aligned for
# efficiency reasons. However, there are machines which are known not
# to boot with misaligned GDTs, so alter this at your peril! If you alter
# GDT_ENTRY_BOOT_CS (in asm/segment.h) remember to leave at least two
# empty GDT entries (one for NULL and one reserved).
# NOTE: On some CPUs, the GDT must be 8 byte aligned. This is
# true for the Voyager Quad CPU card which will not boot without
# This directive. 16 byte aligment is recommended by intel.
 .align 16
gdt:
 .word gdt_end - gdt - 1 # gdt limit
 .long (0x2000 * 16 + gdt - _start1) # linear address of gdt
 .word 0 # pad 2 bytes
 .word 0xFFFF, 0
 .byte 0x20, 0x92, 0, 0
 .word 0xFFFF, 0
 .byte 0, 0x92, 0, 0
gdt_end:
helper_start:
# 5361 "grldrstart.S"
 sti
 pushw %cs
 popw %ds
 pushw $0xd00
 popw %es
# 5385 "grldrstart.S"
 pushw %ds
 pushw %es
 pushal
 pushfw
 testb $0x0C, %cs:0x02
 jz 1f
 pushw %es
 xorw %ax, %ax
 movw %ax, %es
 movw $0x5FC, %di
 movl $0x45435544, %eax
 movb %cs:0x02, %al
 andb $0x0C, %al
 orb $0x40, %al
 stosl
 popw %es
1:
 testb $0x80, %cs:0x02
 jnz 2f
# 5418 "grldrstart.S"
   cmpb $0, %cs:0x03
   je 1f
 movw $(press_hot_key_pre - _start1), %si
 call print_message
 movw $(press_hot_key_name - _start1), %si
 call print_message
 movw $(press_hot_key_sub - _start1), %si
 call print_message
1:
 call sleep_5_seconds
 jc 3f
 call boot_prev_mbr
 jmp 3f
2:
   cmpb $0, %cs:0x03
   je 1f
 movw $(press_hot_key_pre - _start1), %si
 call print_message
 movw $(press_hot_key_name - _start1), %si
 call print_message
 movw $(press_hot_key_sub1 - _start1), %si
 call print_message
1:
 call sleep_5_seconds
 jnc 3f
 andb $0x7F, %cs:0x02
 call boot_prev_mbr
3:
 movw $(0xEB | ((4f - 2b - 2) << 8)), (2b - _start1)
 orb $0x80, %cs:0x02
4:
 popfw
 popal
 popw %es
 popw %ds
 pushw %ds
 pushw %es
 pushal
 pushfw
 movb $0x02, 0x00
 movb $0x41, %ah
 movw $0x55aa, %bx
 call int13
 jc 1f
 cmpw $0xaa55, %bx
 jnz 1f
 testb $1, %cl
 jz 1f
 movb $0x42, 0x00
1:
 popfw
 popal
 popw %es
 popw %ds
 pushw %ds
 pushw %es
 pushal
 pushfw
 pushaw
 cmpw $0x1c2, %si
 jne 1f
 movw $0xffff, 0x1bc
 movw $0x01fe, 0x1ba
1:
 pushw %dx
 pushw %ds
 pushw %es
 call geometry_tune
 popw %es
 popw %ds
 testb %dl, %dl
 jns 2f
 cmpw $0x1f2, %si
 ja 2f
 movl 4(%si), %eax
 movl %eax, 8(%si)
 xorl %eax, %eax
 movl %eax, 4(%si)
2:
 cmpw $0xFFFF, 0x08
 jne 3f
 movb $8, %ah
 call int13
 jc 3f
 testb $63, %cl
 jz 3f
 movb %dh, 0x09
 andb $63, %cl
 movb %cl, 0x08
3:
 movl $32, %ebx
 testb %dl, %dl
 jns 3f
 movl 4(%si), %ebx
 addl 8(%si), %ebx
 testl %ebx, %ebx
 je 1f
3:
 cmpb $0x42, 0x00
 je 3f
 movw $0, %bp
 movw 0x08, %ax
 movw %ax, %dx
 movb $0, %dh
 movw %dx, 0x18
 movb %ah, %dl
 incw %dx
 movw %dx, 0x1a
 popw %ax
 pushw %ax
 movb %al, 0x24
 pushw (jc_code_begin - _start1)
 movw $(0xEB | ((jc_code_end - jc_code_begin - 2) << 8)), (jc_code_begin - _start1)
 pushw %es
 pushl %ebx
 pushl %ebx
 xorw %bx, %bx
 movw $4, %cx
 testb %al, %al
 js 2f
 movw $1, %cx
 movw $0x4000, %bx
2:
 popw %ax
 popw %dx
 call readDisk_12_16
 popl %ebx
 popw %es
 popw (jc_code_begin - _start1)
 cmpb $0x42, 0x00
 jne 1f
3:
 popw %ax
 pushw %ax
 xorw %dx, %dx
 pushw %dx
 pushw %dx
 pushl %ebx
 pushw %es
 pushw %dx
 pushw $0x3f
 pushw $0x10
 xchgw %ax, %dx
 movb $0x42, %ah
 movw %sp, %si
 call int13
 popaw
 jc 1f
 popw %dx
 popaw
 popfw
 clc
 pushfw
 pushaw
 pushw %dx
1:
 popw %dx
 popaw
 popfw
 popal
 popw %es
 popw %ds
 pushw %ds
 pushw %es
 pushal
 pushfw
 pushw %si
 pushfw
 pushw %es
 pushw %ds
 popw %es
 cld
 xorw %ax, %ax
 testb %dl, %dl
 jns 1f
# 5675 "grldrstart.S"
 incw 0x1bc
 movw 0x1bc, %ax
 cmpb $4, %al
 jb 1f
 movb $0xFC, (add_sub_si + 2 - _start1)
1:
 pushw %ax
 movw $(partition_message - _start1 + 7), %di
 movb %dl, %al
 shrb $7, %al
 shlb $1, %al
 addw $0x6466, %ax
 stosw
 movb %dl, %al
 andb $0x7f, %al
 aam
 testb %ah, %ah
 jz 1f
 addb $0x30, %ah
 movb %ah, (%di)
 incw %di
1:
 addb $0x30, %al
 stosb
 popw %ax
 testb %dl, %dl
 jns 2f
 movb $0x2c, (%di)
 incw %di
 aam
 testb %ah, %ah
 jz 1f
 addb $0x30, %ah
 movb %ah, (%di)
 incw %di
1:
 addb $0x30, %al
 stosb
2:
 movl $0x00203a29, (%di)
 movw $(partition_message - _start1), %si
 call print_message
 popw %es
 popfw
 jc invalid_or_null
 xorw %si, %si
 pushw %es
 popw %ds
 cmpw $0xEF53, 0x438
 jnz 1f
 xorl %eax, %eax
 cmpl %eax, 0x400
 jz 1f
 cmpl %eax, 0x404
 jz 1f
 cmpl %eax, 0x420
 jz 1f
 cmpl %eax, 0x428
 jz 1f
 movl 0x414, %eax
 movw %ax, %bx
 shrl $1, %eax
 jnz 1f
 movl 0x418, %ecx
 cmpl $4, %ecx
 ja 1f
 negw %cx
 adcw %ax, %bx
 decw %bx
 jnz 1f
 movw $0x80, %ax
 movw %ax, %cs:0x826
 movl 0x44C, %ecx
 jecxz 3f
 movw 0x458, %ax
 testw %ax, %ax
 jz 1f
 pushw %ax
 pushw %dx
 movb 0x418, %cl
 addb $10, %cl
 xorw %dx, %dx
 incw %dx
 shlw %cl, %dx
 xchgw %ax, %cx
 xchgw %ax, %dx
 xorw %dx, %dx
 divw %cx
 testw %dx, %dx
 popw %dx
 popw %ax
 jnz 1f
 movw %ax, %cs:0x826
3:
# 5798 "grldrstart.S"
 cld
 movw $0x800, %si
 xorw %di, %di
 movw $0x0200, %cx
 repz cs movsw
 testb %dl, %dl
 jns 3f
 movw $0x25, %di
 movw %cs:0x1bc, %ax
 stosb
3:
 popw %si
 pushw %si
 xorl %eax, %eax
 testb %dl, %dl
 jns 3f
 movl %cs:4(%si), %eax
 addl %cs:8(%si), %eax
3:
 movl %eax, %es:0x1c(%bx)
 movb %cs:0x00(%bx), %al
 movb %al, %es:0x02(%bx)
 movb %es:0x418, %cl
 movl $2, %eax
 shlw %cl, %ax
 movb %al, %es:0x0d(%bx)
 shlw $9, %ax
 movw %ax, %es:0x0e(%bx)
 shrw $2, %ax
 movl %eax, %es:0x14(%bx)
 addb $8, %cl
 shll %cl, %eax
 movl %eax, %es:0x10(%bx)
 movw %cs:0x08(%bx), %ax
 cmpw $0xFFFF, %ax
 jz 3f
 movb %al, %es:0x18(%bx)
 shrw $8, %ax
 incw %ax
 movw %ax, %es:0x1a(%bx)
3:
# 5878 "grldrstart.S"
 movl %es:0x428, %eax
 movl %eax, %es:0x28(%bx)
 movl %es:0x414, %eax
 incw %ax
 movl %eax, %es:0x2c(%bx)
 movw $0x01fc, %si
 movw %si, %di
 lodsw
 cmpw $0xFEEB, %ax
 jnz 3f
 decw %ax
 stosb
 movw $0x8410, %ax
 stosw
 xorw %ax, %ax
 stosw
3:
 movw $(EXT2_message - _start1), %si
 call print_message
 clc
 jmp move_entries_and_return
1:
 #; It is not EXT2. Check for FAT12/16/32/NTFS.
 testb %dl, %dl
 js 3f
 movb $0xff, %cs:0x1bc
 movl 0x401C, %eax
 cmpl $0x20, %eax
 jne 3f
 xorw %bx, %bx
 movw $0x1C6, %di
 movw $4, %cx
8:
 cld
 scasl
 jne 2f
 incw %si
 movb %bl, %cs:0x1bc
2:
 addw $12, %di
 incw %bx
 loop 8b
 decw %si
 jnz 3f
 movb $0, %al
 movw $0x0B, %di
 movw $(0x5A - 0x0B), %cx
 cld
 repz scasb
 jnz 3f
 movw $0x400B, %si
 movw $0x0B, %di
 movw $(0x5A - 0x0B), %cx
 cld
 repz movsw
 xchgb %al, 0x1C
 addw %ax, 0x0E
3:
 xorw %si, %si
 cmpw $0x200, 0x0b(%si)
 jne 1f
 movb 0x0d(%si), %al
 testb %al, %al
 jz 1f
 movb %al, %cl
 movw $128, %ax
 divb %cl
 testb %ah, %ah
 jnz 1f
 movw 0x18(%si), %ax
 testw %ax, %ax
 jz 1f
 cmpw $63, %ax
 ja 1f
 movw 0x1a(%si), %ax
 decw %ax
 testb %ah, %ah
 jnz 1f
 cmpb $0xf0, 0x15(%si)
 jb 1f
 cmpb $0x42, %cs:0x00
 jne 3f
# 5991 "grldrstart.S"
 movb $0x0e, 0x02(%si)
3:
 cld
 movw $0x0600, %bx
 movw $0x003c, %cx
 movb 0x10(%si), %al
 cmpb $2, %al
 ja 1f
 movw 0x11(%si), %ax
 testw %ax, %ax
 jnz 2f
 movw 0x13(%si), %ax
 testw %ax, %ax
 jnz 1f
 movw 0x16(%si), %ax
 testw %ax, %ax
 jnz 1f
 movb 0x10(%si), %al
 testb %al, %al
 jz 8f
 movl 0x20(%si), %eax
 testl %eax, %eax
 jz 1f
 movl 0x24(%si), %eax
 testl %eax, %eax
 jz 1f
 movw $0x0400, %bx
 movw $0x0058, %cx
 movw $(FAT32_message - _start1), %si
 jmp 7f
8:
 movl 0x20(%si), %eax
 testl %eax, %eax
 jnz 1f
 movw 0x0e(%si), %ax
 testw %ax, %ax
 jnz 1f
 movw %cs:0x08(%si), %ax
 cmpw $0xFFFF, %ax
 jz 3f
 movb %al, 0x18(%si)
 shrw $8, %ax
 incw %ax
 movw %ax, 0x1a(%si)
3:
 popw %si
 pushw %si
 xorl %eax, %eax
 testb %dl, %dl
 jns 3f
 movl %cs:4(%si), %eax
 addl %cs:8(%si), %eax
3:
 movl %eax, 0x1c
 movb %dl, 0x24
 movw $(NTFS5_message - _start1), %si
 call print_message
 movw $0xA00, %bx
 movw $0x52, %cx
 pushw %cs
 popw %ds
 movw %bx, %si
 xorw %di, %di
 lodsw
 stosw
 addw %cx, %si
 addw %cx, %di
 movw $0x800, %cx
 subw %di, %cx
 repz movsb
 movb %es:1, %al
 addb $5, %al
 cbw
 xchgw %ax, %di
 movb 0x1bc, %al
 stosb
 movw $0x01fa, %di
 movw %es:(%di), %ax
 cmpw $0xFEEB, %ax
 jnz 3f
 decw %ax
 stosb
 movw $0x8410, %ax
 stosw
 xorw %ax, %ax
 stosw
3:
 clc
 jmp move_entries_and_return
# 6147 "grldrstart.S"
2:
 xorw %si, %si
 movb 0x10(%si), %al
 testb %al, %al
 jz 1f
 movw 0x16(%si), %ax
 testw %ax, %ax
 jz 1f
 movw $(FAT16_message - _start1), %si
 cmpw $12, %ax
 ja 7f
 movw $(FAT12_message - _start1), %si
7:
 pushw %bx
 pushw %cx
 call print_message
 popw %cx
 popw %bx
 xorw %si, %si
 movw %cs:0x08(%si), %ax
 cmpw $0xFFFF, %ax
 jz 3f
 movb %al, 0x18(%si)
 shrw $8, %ax
 incw %ax
 movw %ax, 0x1a(%si)
3:
 popw %di
 pushw %di
 xorl %eax, %eax
 testb %dl, %dl
 jns 3f
 movl %cs:4(%di), %eax
 addl %cs:8(%di), %eax
3:
 movl %eax, 0x1c
 pushw %cs
 popw %ds
 movw %bx, %si
 xorw %di, %di
 lodsw
 stosw
 addw %cx, %si
 addw %cx, %di
 movw $0x0200, %cx
 subw %di, %cx
 repz movsb
 movb %es:1, %al
 addb $5, %al
 cbw
 xchgw %ax, %di
 movb 0x1bc, %al
 stosb
 movw $0x01fa, %di
 movw %es:(%di), %ax
 cmpw $0xFEEB, %ax
 jnz 3f
 decw %ax
 stosb
 movw $0x8410, %ax
 stosw
 xorw %ax, %ax
 stosw
3:
 clc
 jmp move_entries_and_return
1:
 #; It is not FAT12/16/32/NTFS. Check for extended partition.
 pushw %cs
 popw %es
 popw %si
 pushw %si
 cmpb $0x05, %es:(%si)
 je 1f
 cmpb $0x0f, %es:(%si)
 je 1f
 cmpb $0x15, %es:(%si)
 je 1f
 cmpb $0x1f, %es:(%si)
 je 1f
 cmpb $0x85, %es:(%si)
 je 1f
 movw $(non_MS_message - _start1), %si
4:
 call print_message
 stc
 jmp move_entries_and_return
1:
 cmpw $0x1fe, %si
 jb 1f
 decw %es:0x1bc
1:
 movw $(extended_message - _start1), %si
 call print_message
 movw $0x1be, %si
 movw $4, %cx
5:
 movl (%si), %eax
 cmpw 2(%si), %ax
 jnz 2f
 cmpb %al, %ah
 jnz 2f
 cmpl %eax, 4(%si)
 jnz 2f
 cmpl %eax, 8(%si)
 jnz 2f
 cmpl %eax, 12(%si)
 jz 3f
2:
 movb (%si), %al
 shlb $1, %al
 jnz 1f
 movb 2(%si), %al
 and $63, %al
 jz 1f
 movb 6(%si), %al
 and $63, %al
 jz 1f
 movl 8(%si), %eax
 testl %eax, %eax
 jz 1f
 movl 12(%si), %eax
 testl %eax, %eax
 jz 1f
3:
 addw $16, %si
 loop 5b
 cmpw $0xaa55, (%si)
 jnz 1f
 movw $0x1be, %si
 movw $4, %cx
 popw %bx
 pushw %bx
5:
 movl (%si), %eax
 cmpw 2(%si), %ax
 jnz 2f
 cmpb %al, %ah
 jnz 2f
 cmpl %eax, 4(%si)
 jnz 2f
 cmpl %eax, 8(%si)
 jnz 2f
 cmpl %eax, 12(%si)
 jz 3f
2:
 movw %es:0x1ba, %di
 cmpw $0x83f0, %di
 ja 3f
 cmpw $0x3fe, %di
 jne 6f
 movw $0x7e00, %di
 movw %di, %es:0x1ba
6:
 addw $16, %es:0x1ba
 lodsl
 stosl
 lodsl
 stosl
 xchgw %ax, %dx
 lodsl
        xchgl %eax, %edx
 cmpb $0x05, %al
 je 6f
 cmpb $0x0f, %al
 je 6f
 cmpb $0x15, %al
 je 6f
 cmpb $0x1f, %al
 je 6f
 cmpb $0x85, %al
 je 6f
 addl %es:4(%bx), %edx
6:
        xchgl %eax, %edx
 stosl
 lodsl
 movl %es:8(%bx), %eax
 stosl
 jmp 2f
3:
 addw $16, %si
2:
 loop 5b
 stc
 jmp move_entries_and_return
invalid_or_null:
1:
 movw $(invalid_message - _start1), %si
 call print_message
 stc
move_entries_and_return:
 popw %si
 pushfw
 pushw %cs
 popw %ds
 pushw %cs
 popw %es
 pushw %si
 cmpw $0x202, %si
 jne 1f
 movw $0x1fe, %di
 movw $0x20e, %si
 movw $0xf8, %cx
 cld
 repz movsw
 movw $0x3ee, %di
 movw $0x7e00, %si
 movw $0x8, %cx
 cld
 repz movsw
 movw $0x7e00, %di
 movw $0x7e10, %si
 movw $0x2f8, %cx
 cld
 repz movsw
 cmpw $0x7e10, 0x1ba
 jne 2f
 movw $0x40e, 0x1ba
2:
 subw $0x10, 0x1ba
1:
 popw %si
 movw $0x1fe, %ax
 movw $(add_sub_si + 5 - _start1), %di
 movw %ax, (%di)
 cmpw $0x31b2, %si
 je 4f
 incw (%di)
 cmpw %ax, 0x1ba
 jne 1f
 decw (%di)
 cmpw $0x1f2, %si
 ja 2f
 jb 1f
 cmpw $0x0003, 0x1bc
 ja 1f
2:
inc_hard_drive:
# 6474 "grldrstart.S"
 xorw %ax, %ax
 movw %ax, %ds
 movb 0x475, %dh
 pushw %cs
 popw %ds
 orb $0x80, %dh
 movw %sp, %bp
 movb 24(%bp), %dl
2:
 jnc 3f
 call print_message
 movw $(drive_number_string - _start1), %si
 movb %dl, %al
 andb $0x7f, %al
 aam
 addw $0x3030, %ax
 xchgb %al, %ah
 movw %ax, 32(%si)
 call print_message
3:
 incw %dx
 cmpb %dh, %dl
 jnb 2f
 pushw %bx
 movb $8, %ah
 call int13
 jc 3f
 andb $63, %cl
 stc
 jz 3f
 popw %bx
 movb %dl, %ch
 pushw %cx
 movw $0x201, %ax
 movw $0x7e00, %bx
 movw $1, %cx
 xorb %dh, %dh
 call int13
 sti
3:
 popw %bx
 movw $(Error_while_reading_string - _start1), %si
 jc 2b
 testb %ah, %ah
 stc
 jnz 2b
 movw $0x7fbe, %si
 movw $0x01be, %di
3:
 cmpw $0x1fe, %di
 jnb 3f
 xorl %ecx, %ecx
 lodsl
 stosl
 orl %eax, %ecx
 lodsl
 stosl
 orl %eax, %ecx
 lodsl
 stosl
 orl %eax, %ecx
 lodsl
 stosl
 orl %eax, %ecx
 jecxz 3b
 movb -16(%si), %al
 shlb $1, %al
 stc
 xchgw %ax, %si
 movw $(partition_boot_indicator_string - _start1), %si
 jnz 2b
 xchgw %ax, %si
 movb -14(%si), %al
 andb $63, %al
 stc
 xchgw %ax, %si
 movw $(partition_sectors_per_track_string - _start1), %si
 jz 2b
 xchgw %ax, %si
 movb -10(%si), %al
 andb $63, %al
 stc
 xchgw %ax, %si
 movw $(partition_sectors_per_track_string - _start1), %si
 jz 2b
 xchgw %ax, %si
 movl -8(%si), %eax
 testl %eax, %eax
 stc
 xchgw %ax, %si
 movw $(partition_start_sector_string - _start1), %si
 jz 2b
 xchgw %ax, %si
 movl -4(%si), %eax
 testl %eax, %eax
 stc
 xchgw %ax, %si
 movw $(partition_end_sector_string - _start1), %si
 jz 2b
 xchgw %ax, %si
 jmp 3b
3:
 cmpw $0xAA55, (%si)
 stc
 xchgw %ax, %si
 movw $(no_boot_signature_string - _start1), %si
 jnz 2b
 xchgw %ax, %si
 movw %bx, 12(%bp)
 movw $0x1b2, 8(%bp)
# 6634 "grldrstart.S"
 movb $0xE8, (add_sub_si - _start1)
 movw $(self_modify_once - add_sub_si - 3), (add_sub_si + 1 - _start1)
 movw $0xffff, 0x1bc
 movw $0x01fe, 0x1ba
 jmp 1f
2:
# 6651 "grldrstart.S"
4:
# 6661 "grldrstart.S"
 movb $0xE9, (Error_or_prev_MBR - _start1)
 movw $(Error_modify - Error_or_prev_MBR - 3), (Error_or_prev_MBR + 1 - _start1)
# 6673 "grldrstart.S"
 movb 0x02, %al
 andb $0x01, %al
 subb %al, (add_sub_si + 5 - _start1)
1:
# 6694 "grldrstart.S"
 popw %ax
 popfw
 lahf
 shlb $2, %ah
 rorw $2, %ax
 sahf
 jc 1f
 popal
 pushal
 pushfw
 cmpb $0xff, %cs:0x06
 jz 2f
 movb %cs:0x1bc, %dh
 testb %dl, %dl
 js 3f
 movb $0xff, %dh
3:
 cmpw %cs:0x06, %dx
 jz 2f
 popfw
 stc
 pushfw
2:
 popfw
1:
 popal
 popw %es
 popw %ds
 ret
self_modify_once:
 addw $12, %si
 movw %bp, %ax
 movb %ah, %dl
 movw $0xC683, (add_sub_si - _start1)
 movb $0x0C, (add_sub_si + 2 - _start1)
 ret
Error_modify:
 cmpb $0xff, %cs:0x06
 jz 1f
 movb $0xff, %cs:0x06
 movb $0x7f, %dl
 stc
 pushw $(helper_call + 3 - _start1)
 pushw %cs
 pushw $0xd00
 pushal
# 6770 "grldrstart.S"
 pushfw
 pushfw
 pushw %cs
 popw %es
 jmp inc_hard_drive
1:
boot_prev_mbr:
 xorw %ax, %ax
 movw %ax, %es
 movw %ax, %ds
 movw $0x0202, %ax
 movw $0x7A00, %bx
 movw $0x0001, %cx
 movw $0x0080, %dx
 call int13
 sti
 jc 1f
 testb %ah, %ah
 jnz 1f
 cmpw $0xAA55, 0x7dfe
 jne 1f
 cmpw $0xAA55, 0x7bfe
 jne 1f
 movw $0x7dbe, %si
3:
 cmpw $0x7dfe, %si
 jnb 3f
 movw $4, %cx
 movw %si, %di
2:
 lodsl
 negl %eax
 jc 2f
 loop 2b
 jmp 3b
2:
 movw %di, %si
 lodsw
 shlb $1, %al
 jnz 2f
 lodsw
 andb $63, %al
 jz 2f
 lodsw
 lodsw
 andb $63, %al
 jz 2f
 lodsl
 negl %eax
 jnc 2f
 lodsl
 negl %eax
 jc 3b
2:
 stc
3:
 pushfw
 testb $2, %cs:0x02
 jz 2f
 popfw
 jc 1f
 pushfw
2:
 popfw
 jc 2f
 movw $0x7bb8, %si
 movw $0x7db8, %di
 movw $36, %cx
 cld
 repz movsw
2:
 testb $0x80, %cs:0x02
 jz 2f
 movw $(Cannot_find_GRLDR_string - _start1), %si
 call print_message
 movw $(nt_boot_image - _start1), %si
 call print_message
 movw $(press_space_bar_string - _start1), %si
 movw $0x3920, %cs:0x04
 movb $15, %cs:0x03
 call print_message
 movw $(prev_MBR_string - _start1), %si
 call print_message
3:
 call sleep_5_seconds
 movb $0xff, %cs:0x03
 jc 3b
2:
 movl $0, 0x5FC
 ljmp $0, $0x7c00
1:
 testb $0x80, %cs:0x02
 jnz 1f
 movw $(continue_string - _start1), %si
 call print_message
 call sleep_5_seconds
 ret
1:
 movw $(message_string_helper - _start1), %si
 call print_message
 movw $(nt_boot_image - _start1), %si
 call print_message
 movw $(ctrl_alt_del_string - _start1), %si
 call print_message
1: jmp 1b
sleep_5_seconds:
 pushw %ds
 pushl %esi
 pushl %edx
 movl $0xffffffff, %edx
 movzbl %cs:0x03, %eax
 cmpb $0xff, %al
 je 1f
 movl $18, %edx
 mulw %dx
 xchgw %ax, %dx
1:
 xorw %ax, %ax
 movw %ax, %ds
 movl 0x46c, %eax
 movl %eax, %ecx
 testl %edx, %edx
 js 1f
 addl %edx, %eax
 pushl %eax
 movzbl %cs:0x03, %eax
 orl %eax, %eax
 jz 3f
 movw $(hot_key_timeout_pre - _start1), %si
 pushl %eax
 call print_message
 popl %eax
 movw $(hot_key_timeout_num - _start1), %si
 call print_decimal
3:
 movl %ecx, %esi
 addl $18, %esi
 popl %eax
 jmp 3f
1:
 movl %edx, %eax
 movl %edx, %esi
3:
 movl 0x46c, %ebx
 cmpl %ecx, %ebx
 jnb 2f
 xorl %ecx, %ecx
 movl %edx, %eax
 movl $18, %esi
2:
 pushl %eax
 movb $1, %ah
 int $0x16
 pushw %ax
 pushfw
 movb $0x11, %ah
 int $0x16
 jnz 1f
 popfw
 jnz 2f
 popw %ax
 popl %eax
 cmpl %esi, %ebx
 jb 4f
 pushl %esi
 pushl %eax
 pushl %edx
 subl %esi, %eax
 xorl %edx, %edx
 movl $18, %esi
 divl %esi
 movw $(hot_key_timeout_num - _start1), %si
 pushl %ebx
 call print_decimal
 popl %ebx
 popl %edx
 popl %eax
 popl %esi
 addl $18, %esi
4:
 cmpl %eax, %ebx
 jbe 3b
 popl %edx
 popl %esi
 popw %ds
 ret
1:
 popfw
2:
# 7041 "grldrstart.S"
 xorw %cs:0x04, %ax
 popw %ax
 je 1f
 xorw %cs:0x04, %ax
 jne 2f
 movb $0, %ah
 int $0x16
 jmp 3f
1:
 movb $0x10, %ah
 int $0x16
3:
 stc
2:
 popl %eax
 popl %edx
 popl %esi
 popw %ds
 ret
out_decimal:
 pushl %edx
 pushl %ecx
 pushw %bx
 movl $10, %ecx
 movw %si, %bx
1:
 xorl %edx, %edx
 divl %ecx
 addb $'0', %dl
 movb %dl, %cs:(%si)
 incw %si
 orl %eax, %eax
 jnz 1b
 pushw %si
1:
 decw %si
 cmpw %bx, %si
 jbe 1f
 movb %cs:(%si), %al
 xchgb %al, %cs:(%bx)
 movb %al, %cs:(%si)
 incw %bx
 jmp 1b
1:
 popw %si
 popw %bx
 popl %ecx
 popl %edx
 ret
print_decimal:
 pushw %si
 call out_decimal
1:
 cmpb $'\b', %cs:(%si)
 jz 2f
 movb $' ', %cs:(%si)
 incw %si
 jmp 1b
2:
 popw %si
 call print_message
 ret
# 7402 "grldrstart.S"
move_helper:
 pushw %si
 pushw %bx
 pushl %eax
 movw $0x0003, %ax
 int $0x10
 movw $0x200, %si
 movw %si, %di
 movw $0x3E00, %cx
 cld
 repz movsw
 popl %eax
 popw %bx
 popw %si
 ret
# 7430 "grldrstart.S"
filesystem_boot:
 pushw %ds
 pushw %es
 pushal
 movw %es, %bx # save old ES to BX
 cli
 lgdt gdt - _start1
 movl %cr0, %eax
 orb $1, %al
 movl %eax, %cr0
 movw $8, %si
 movw %si, %es
 xorl %esi, %esi
 xorl %edi, %edi
 movl $(0x9000 / 4), %ecx
 cld
 repz movsl
 movw $16, %si
 movw %si, %es
 andb $0xfe, %al
 movl %eax, %cr0
 movw %bx, %es # restore ES from BX
 movw $0x0400, %cx
 xorw %si, %si
 pushw %si
 movw $0x7c00, %di
 pushw %di
 pushw %es
 popw %ds
 pushw %si
 popw %es
 cld
 repz movsw
 movw $0x8410, %di
 movw $(restore_GRLDR_CS - _start1), %si
 movw $((gdt_end - restore_GRLDR_CS) / 4), %cx
 cld
 repz cs movsl
 pushw %es
 popw %ds
 sti
 lret
geometry_tune:
# 7521 "grldrstart.S"
 testb %dl, %dl
 jns 1f
 cmpw $0x1c2, %si
 jne 2f
1:
 movw $0xffff, 0x08
 cmpb $0x42, 0x00
 je 2f
 #; real geometry tune follows. if you wish to disable the tune,
 #; just do a 'ret' here.
 testb $0x08, 0x02
 jnz 2f
 cmpl $0xAA555247, (grldr_signature - _start1)
 je real_geometry_tune
2:
 ret
press_space_bar_string:
 .ascii "\r\nPress space bar\0"
press_hot_key_pre:
 .ascii "\r\nPress \0"
press_hot_key_sub:
 .ascii " to start GRUB, any other key to boot previous MBR ...\0"
press_hot_key_sub1:
 .ascii " to boot previous MBR, any other key to start GRUB ...\0"
hot_key_timeout_pre:
 .ascii "\r\nTimeout: \0"
hot_key_timeout_num:
 .ascii "   \b\b\b\0"
continue_string:
 .ascii "\r\nInvalid previous MBR. Press any key to start GRUB ...\0"
prev_MBR_string:
 .ascii " to hold the screen, any other key to boot previous MBR ...\0"
Error_while_reading_string:
 .ascii "\r\nError while reading MBR of \0"
drive_number_string:
 .ascii " in partition table of drive (hd0 ) \0"
partition_boot_indicator_string:
partition_sectors_per_track_string:
partition_start_sector_string:
partition_end_sector_string:
no_boot_signature_string:
 .ascii "\r\nError\0"
Cannot_find_GRLDR_string:
message_string_helper:
 .ascii "\r\nCannot find \0"
ctrl_alt_del_string:
 .ascii " in all drives. Press Ctrl+Alt+Del to restart.\0"
partition_message:
 .ascii "\r\nTry (hd0,0 ) : \0"
EXT2_message:
 .ascii "EXT2: \0"
NTFS5_message:
 .ascii "NTFS5: \0"
FAT32_message:
 .ascii "FAT32: \0"
FAT16_message:
 .ascii "FAT16: \0"
FAT12_message:
 .ascii "FAT12: \0"
non_MS_message:
 .ascii "non-MS: skip \0"
extended_message:
 .ascii "Extended: \0"
invalid_message:
 .ascii "invalid or null \0"
 . = _start1 + 0x1FE8
press_hot_key_name:
 .ascii "hot-key\0"
 ######################################################################
 # The installer should setup the long integer at offset 0x1FFC as
 # the unique disk signature. The same signature value must be also
 # placed into the disk_serial_number_structure in the first sector(the
 # MBR sector). You can easily locate the structure through the pointer
 # at offset 0x1FF8.
 # For GRLDR.MBR the default disk serial number is the grldr.mbr
 # signature(0x93cb4d05). You should change it according to the
 # date-time value just at the time when you run the installer.
 ######################################################################
 . = _start1 + 0x1FF8
 .word disk_serial_number_structure - _start1 + 5
 . = _start1 + 0x1FFA
 .word 4
 . = _start1 + 0x1FFC
 .long 0x93cb4d05
 . = _start1 + 0x2000
real_geometry_tune:
 pushaw
 xorl %eax, %eax
 movl %eax, %cs:(Sectors_passed_in - _start1)
 movl %eax, %cs:(Heads_passed_in - _start1)
 movb $8, %ah
 int $0x13
 jc 1f
 testb $63, %cl
 jz 1f
 andb $63, %cl
 movb %cl, %cs:(Sectors_passed_in - _start1)
 incb %dh
 movb %dh, %cs:(Heads_passed_in - _start1)
1:
 popaw
 movzbw %cs:(Sectors_passed_in - _start1), %cx
 pushw %cx
 movzbw %cs:(Heads_passed_in - _start1), %cx
 pushw %cx
 movzbw %dl, %cx
 pushw %cx
 pushw $(BIOS_geom_string - _start1)
 call realmode_printf
 addw $8, %sp
 movw %cs:(Sectors_passed_in - _start1), %cx
 call check_sector_readable
 jnc 1f
 xorw %cx, %cx
1:
 cmpw $63, %cx
 jnb 2f
 incw %cx
 call check_sector_readable
 jc 1f
 cmpw $63, %cx
 jb 1b
 jmp 2f
1:
 decw %cx
 cmpb $2, %cl
 jnb 2f
 movb $1, %ah
 ret
check_sector_readable:
 movw $0x5000, %ax
 movw %ax, %es
 movw %ax, %ds
 xorw %bx, %bx
 movw $0x201, %ax
 movb $0, %dh
 pushaw
 movw %bx, %si
 movw %bx, %di
 int $0x13
 popaw
 ret
2:
 cmpw $63, %cx
 jbe 2f
 movw $63, %cx
2:
 movw %cx, %cs:(Smax_tuned - _start1)
# 7852 "grldrstart.S"
 movb %cs:(Heads_passed_in - _start1), %dh
 testb %dh, %dh
 jz 1f
 call tune_heads
 jb 2f
 ja 4f
1:
 movb $1, %dh
1:
 call tune_heads
 jb 2f
 ja 4f
 incb %dh
 jnz 1b
4:
 decb %dh
 movb %dh, %cs:(Hmax_tuned - _start1)
5:
 cmpb $0xFF, %dh
 jne 1f
 movb %cs:(Heads_passed_in - _start1), %dh
 testb %dh, %dh
 jnz 4f
 decb %dh
4:
 decb %dh
 movb %dh, %cs:(Hmax_tuned - _start1)
1:
 movb %cs:(Sectors_passed_in - _start1), %cl
4:
 call tune_sectors
 jb 2f
 ja 4f
1:
 movb $8, %cl
1:
 call tune_sectors
 jb 2f
 ja 4f
 incw %cx
 cmpb %cs:(Smax_tuned - _start1), %cl
 jb 1b
 cmpb $63, %cl
 jbe 4f
 movb $63, %cl
4:
 movb %cl, %cs:(Smax_tuned - _start1)
 movzbw %cs:(Smax_tuned - _start1), %cx
 pushw %cx
 movzbw %cs:(Hmax_tuned - _start1), %cx
 incw %cx
 pushw %cx
 movzbw %dl, %cx
 pushw %cx
 pushw $(TUNE_geom_string - _start1)
 call realmode_printf
 addw $8, %sp
 movw %cs:(Smax_tuned - _start1), %cx
 movb %cs:(Hmax_tuned - _start1), %dh
 movb %cl, %cs:0x08
 movb %dh, %cs:0x09
 movb $0, %ah
 ret
2:
 movb $1, %ah
 ret
tune_heads:
 movb $0, %ch
2:
 movb $1, %cl
 movb $2, %ah
 movb %cs:(Smax_tuned - _start1), %al
 movw $0x5000, %bx
 movw %bx, %es
 movw %bx, %ds
 xorw %bx, %bx
 pushaw
 movw %bx, %si
 movw %bx, %di
 int $0x13
 popaw
 incb %ch
 jc 4f
 decb %ch
 movb $1, %cl
 movb $2, %ah
 movb %cs:(Smax_tuned - _start1), %al
 movw $0x5800, %bx
 movw %bx, %es
 movw %bx, %ds
 xorw %bx, %bx
 pushaw
 movw %bx, %si
 movw %bx, %di
 movb $0, %dh
 int $0x13
 popaw
 jc 2f
 incb %ch
 call cmp_track
 je 4f
 movb $1, %cl
 movb $2, %ah
 movb %cs:(Smax_tuned - _start1), %al
 movw $0x5800, %bx
 movw %bx, %es
 movw %bx, %ds
 xorw %bx, %bx
 pushaw
 movw %bx, %si
 movw %bx, %di
 movb $0, %dh
 int $0x13
 popaw
 jc 2f
 call cmp_track
 jne 3f
4:
 cmpb $5, %ch
 jb 2b
 cmpb $0, %dh
 je 2f
 ret
3:
 cmpb %dh, %dh
 ret
2:
 stc
 ret
cmp_track:
 pushw %cx
 pushw %si
 pushw %di
 movw %cs:(Smax_tuned - _start1), %cx
 shlw $7, %cx
 movw $0x5000, %ax
 movw %ax, %ds
 movw $0x5800, %ax
 movw %ax, %es
 xorw %si, %si
 xorw %di, %di
 cld
 repz cmpsl
 popw %di
 popw %si
 popw %cx
 ret
tune_sectors:
 movw $16, %cs:(Smax_count - _start1)
 movb $0, %ch
 movb $0, %dh
6:
 movw $0x201, %ax
 movw $0x5800, %bx
 movw %bx, %es
 movw %bx, %ds
 xorw %bx, %bx
 pushaw
 movb $1, %cl
 movw %bx, %si
 movw %bx, %di
 int $0x13
 popaw
 jc 2f
 movw $0x202, %ax
 movw $0x5000, %bx
 movw %bx, %es
 movw %bx, %ds
 xorw %bx, %bx
 pushaw
 movw %bx, %si
 movw %bx, %di
 int $0x13
 popaw
 pushfw
 cmpb %cs:(Hmax_tuned - _start1), %dh
 jb 3f
 movb $0xFF, %dh
 incb %ch
3:
 incb %dh
 popfw
 jc 4f
 call cmp_sector
 je 4f
 movw $0x201, %ax
 movw $0x5800, %bx
 movw %bx, %es
 movw %bx, %ds
 xorw %bx, %bx
 pushaw
 movw %bx, %si
 movw %bx, %di
 movb $1, %cl
 int $0x13
 popaw
 jc 2f
 call cmp_sector
 jne 3f
4:
 decw %cs:(Smax_count - _start1)
 jz 6f
 cmpb $7, %ch
 jb 6b
6:
 cmpb $1, %cl
 jbe 2f
 ret
3:
 cmpb %cl, %cl
 ret
2:
 stc
 ret
cmp_sector:
 pushw %cx
 pushw %si
 pushw %di
 movw $0x80, %cx
 movw $0x5020, %ax
 movw %ax, %ds
 movw $0x5800, %ax
 movw %ax, %es
 xorw %si, %si
 xorw %di, %di
 cld
 repz cmpsl
 popw %di
 popw %si
 popw %cx
 ret
#;============================================================================
# 8204 "grldrstart.S"
realmode_printf:
 pushaw
 movw %sp, %bp
 # bp+18: format
 # bp+20: variables
 addw $18, %bp
 movw (%bp), %si # points to format string
 addw $2, %bp # (%bp) is the first variable
1:
 cs lodsb
 testb %al, %al
 jz 1f
 cmpb $'%', %al
 jne 2f
 #; %d, %x, %X
 cs lodsb
 testb %al, %al
 jz 1f
 cmpb $'d', %al
 movw $10, %bx # base 10
 jz 4f
 cmpb $'x', %al
 jz 3f
 cmpb $'X', %al
 jne 1b # unkown directive, continue
3:
 movw $16, %bx # base 16
4:
 pushl %edi
 xorl %edi, %edi
 xorw %cx, %cx # count the digits
 movw (%bp), %ax
5:
 xorw %dx, %dx
 divw %bx # AX=quo, DX=rem
 movw %dx, %di
 rorl $4, %edi
 incw %cx
 testw %ax, %ax # end?
 jnz 5b
 xorw %bx, %bx
5:
 roll $4, %edi
 movw %di, %ax # get digit in AL
 andb $0x0f, %al
 cmpb $9, %al
 jbe 6f
 addb $7, %al # A, B, C, D, E, F
6:
 addb $0x30, %al
 movb $0x0e, %ah
 int $0x10
 loop 5b
 popl %edi
 addw $2, %bp # (%bp) is the next variable
 jmp 1b # continue
2:
 xorw %bx, %bx
 movb $0x0e, %ah
 int $0x10
 jmp 1b # continue
1:
 popaw
 ret
#;============================================================================
BIOS_geom_string:
 .string "\r\nBIOS: Drive=0x%X, H=%d, S=%d\r\n"
TUNE_geom_string:
 .string "TUNE: Drive=0x%X, H=%d, S=%d\r\n"
 .align 4
Sectors_passed_in:
 .long 0
Heads_passed_in:
 .long 0
Smax_tuned:
 .word 0
Hmax_tuned:
 .word 0
Smax_count:
 .word 0
cross_track:
 .byte 0
# 8330 "grldrstart.S"
 . = . + (0x3fa - ((. - _start1) % 0x200)) % 0x200
 .word 4
grldr_signature:
 .byte 0x47, 0x52, 0x55, 0xaa
 .align 0x200
# 8352 "grldrstart.S"
 . = . + (0x2000 - (. - _start1)) * (0x4000 / (. - _start1 + 0x2001))
pre_stage2_start:
